<extend name="Public:header"/>
<block name="main-content">
    <section>
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                区域管理列表
            </h3>
            <ul class="breadcrumb">
                <li class="active"> 区域表</li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <section class="panel">
                        <header class="panel-heading">
                            区域管理列表
                    <span class="tools pull-right">
                        <a href="javascript:;" class="fa fa-chevron-down"></a>
                     </span>
                        </header>
                        <div class="panel-body">
                            <div class="adv-table editable-table ">
                                <div class="clearfix">
                                    <div class="btn-group">
                                        <a href="__APP__/admin/Area/create" class="btn btn-primary" type="button">
                                            添加新的区域
                                        </a>
                                    </div>
                                </div>

                                <table class="newtable" id="tableAd">
                                    <thead>
                                    <tr>
                                        <th>区域ID</th>
                                        <th >区域名称</th>
                                        <th >区域图片</th>
                                        <th >是否显示</th>
                                        <th >操作</th>
                                    </tr>
                                    </thead>

                                    <volist name="list" id="vo">
                                        <tr data-id={$vo.id}>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.name}</td>
                                            <td><img src="{$vo.image}" alt="区域图片"></td>
                                            <td>{$vo.is_show}</td>
                                            <td>
                                                <button type="button"  data-id="{$vo.id}" class="btn btn-danger btn-xs delete-ad">
                                                    删除
                                                </button>
                                                <button type="button" data-id="" data-state="" data-title="" data-review="" data-pay="" class="btn btn-primary btn-xs update-ad">
                                                    <a style="color:#fff;" href="__APP__/Admin/Area/update?id={$vo.id}"> 更新</a>
                                                </button>
                                            </td>
                                        </tr>
                                    </volist>
                                </table>
                                {$show}
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>

        <div class="modal fade" id="deleteModel">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">删除提醒</h4>
                    </div>
                    <div class="modal-body">
                        <p>确认删除，删除后无法恢复&hellip;</p>
                    </div>
                    <div class="modal-footer">
                        <input type="hidden" id="adId"/>
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary deleteRemove">确定</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div>
    </section>
</block>
<block name="script">
    <script type="text/javascript">
        $(document).ready(function () {
            $('.delete-ad').on('click',function(){
                var $this=this;
                var id = jQuery($this).data("id");
                $('#adId').val(id);
                $('#deleteModel').modal('show');
            });


            $('.deleteRemove').on('click',function(){
                clearForm();
                var id = $('#adId').val();
                $.ajax({
                    type : "post",
                    url : "__APP__/Admin/Area/delete",
                    dataType : 'json',
                    data : {'id':id},
                    success : function (msg)
                    {
                        if (msg.info == 'ok') {
                            window.location.reload();
                            $('#deleteModel').modal('hide');
                        }else{
                            $('#deleteModel').find('.modal-body').append('<div class="alert alert-danger" role="alert">'+ msg.info +'</div>');
                        }
                    }
                });
            });


            /* 清理FORM */
            function clearForm() {
                $('#createModal').find('.alert-danger').remove();
                $('#UpdateModal').find('.alert-danger').remove();
            }
        });

    </script>
</block>

















